﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MsForgeReboot.Web.Modules
{
    using System.Net.Mail;
    using System.Threading;

    using MsForgeReboot.Framework.Interfaces;

    public class MessageDeliveryModule : IHttpModule
    {
        private readonly IEventService eventService;

        public MessageDeliveryModule(IEventService eventService) {
            this.eventService = eventService;
        }

        public static Timer Scheduler;

        public void Init(HttpApplication context) {
            Scheduler = new Timer(this.ProcessQueue, context, 0, 10000);
        }

        public void Dispose() {
            Scheduler.Dispose();
            Scheduler = null;
        }

        private void ProcessQueue(object data) {

            foreach (var channel in this.eventService.PeekQueue()) {
               //if (deliver) {
               //    delete
               //}
            }

        }
    }
}